package com.zzw.basic.annotion;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

public class TestAnno {

	public static void main(String[] args) throws ClassNotFoundException {
		Class c = Class.forName("com.zzw.basic.annotion.User");
		boolean isExist = c.isAnnotationPresent(Description.class);
		if(isExist){
			Description d = (Description) c.getAnnotation(Description.class);
			System.out.println(d.desc() + "------" + d.author());
		}
		
		Method[] ms = c.getMethods();
		for(Method method:ms){
			boolean isExist1 = method.isAnnotationPresent(Description.class);
			if(isExist1){
				Description d1 = method.getAnnotation(Description.class);
				System.out.println(d1.desc());
			}
		}
		
		for(Method m:ms){
			Annotation[] as = m.getAnnotations();
			for(Annotation a:as){
				if(a instanceof Description){
					Description d = (Description) a;
					System.out.println(d.desc());
				}
			}
		}
	}
}